package com.it.service.impl;

import com.github.pagehelper.PageHelper;
import com.it.dao.GoodsDao;
import com.it.domain.Goods;
import com.it.domain.Goods_Details;
import com.it.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsDao goodsDao;


    /**
     * 新增产品
     * @param goods
     */
    @Override
    public void saveGoods(Goods goods) {
        goodsDao.saveGoods(goods);
    }

    @Override
    public void saveGoods_Details(Goods_Details goods_details) {

        goodsDao.saveGoods_Details(goods_details);
    }

    /**
     * 查询所有货物
     * @return
     */
    @Override
    public List<Goods> findAllGoods(int page,int size) {
        PageHelper.startPage(page,size);
        return goodsDao.findAllGoods();
    }

    /**
     * 根据名称模糊查询货物
     * @param name
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<Goods> FindByName(String name,int page,int size) {
        PageHelper.startPage(page,size);
        return goodsDao.FindByName(name);

    }

    /**
     * 根据id修改信息
     * @param goods
     */
    @Override
    public void changeGoods(Goods goods) {
        goodsDao.changeGoods(goods);
    }

    /**
     * 根据id查询goods表
     * @param id
     * @return
     */
    @Override
    public List<Goods> FindById(int id) {
        return goodsDao.FindById(id);
    }

    /**
     * 根据名称查询goodsdetails表
     * @param name
     * @return
     */
    @Override
    public List<Goods_Details> FindByNameGD(String name) {

        return goodsDao.FindByNameGD(name);
    }

    /**
     * 根据名称修改名称
     * @param
     * @param goods_details
     */
    @Override
    public void ChangeGDName(Goods_Details goods_details/*, int id_d*/) {


        goodsDao.ChangeGDName(goods_details/*,id_d*/);

    }

    /**
     * 根据id删除goods
     * @param id
     */
    @Override
    public void delGoods(int id) {
        goodsDao.delGoods(id);
    }

    /**
     * 根据id删除Goods details所有内容
     * @param id_d
     */
    @Override
    public void delGoodsDetails(int id_d) {
        goodsDao.delGoodsDetails(id_d);

    }

    /**
     * 根据name删除Goods details所有内容
     * @param details
     */
    @Override
    public void delGoodsDetailsBydetails(String details) {
        goodsDao.delGoodsDetailsBydetails(details);
    }

    /**
     * 根据名称查询所有details
     * @param name
     * @return
     */
    @Override
    public List<Goods_Details> SelectGoodsDetails(String name,int page,int size) {
        PageHelper.startPage(page,size);
        return goodsDao.SelectGoodsDetails(name);
    }

    /**
     * 根据details修改goods details信息
     * @param goods_details
     */
    @Override
    public void ChangeDetails(Goods_Details goods_details) {
        goodsDao.ChangeDetails(goods_details);
    }

    /**
     * 根据details改变数量
     * @param goods_details
     * @param
     */
    @Override
    public void IoDGoodsDetails(Goods_Details goods_details) {

        goodsDao.IoDGoodsDetails(goods_details);
    }

    /**
     * 根据details查询数量
     * @param details
     * @return
     */
    @Override
    public int selectQuantity(String details) {
        return goodsDao.selectQuantity(details);
    }

    /**
     * 根据details模糊查询
     * @param details
     * @return
     */
    @Override
    public List<Goods_Details> FindBydetails(String details,int page,int size) {
        PageHelper.startPage(page,size);
        return goodsDao.FindBydetails(details);
    }

    /**
     * 查询所有details
     * @return
     */
    @Override
    public List<Goods_Details> FindAlldetails(int page,int size) {
        PageHelper.startPage(page,size);
        return goodsDao.FindAlldetails();
    }

    /**
     * 按类型查询goods
     * @param Product_Types
     * @return
     */
    @Override
    public List<Goods> FindSomeGoods(String Product_Types,int page,int size) {
        PageHelper.startPage(page,size);
        return goodsDao.FindSomeGoods(Product_Types);
    }

    /**
     * 根据details查询goodsdetails货物
     * @param details
     * @return
     */
    @Override
    public List<Goods_Details> FindGoodsByDetails(String details) {
        return goodsDao.FindGoodsByDetails(details);
    }
}
